from django.contrib import admin
from .models import Question, Choice

# Register your models here.

# Choice 对象要在 Question 后台页面编辑。默认提供 3 个足够的选项字段(extra）。test
class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 3


class QuestionAdmin(admin.ModelAdmin):
    fieldsets = [
        ('问题内容',               {'fields': ['question_text']}),
        ('Date information', {'fields': ['pub_date']}),
    ]
    inlines = [ChoiceInline]

    # 显示页,显示项
    list_display = ('question_text', 'pub_date', 'was_published_recently')
    # 增加过滤器
    list_filter = ['pub_date']
    search_fields = ['question_text']


admin.site.register(Question, QuestionAdmin)
